<template>
    <view>
        <view class="top">
            <view class="blessing">
                {{blessing}}
            </view>
            <view class="money">
                {{grab_money}}
            </view>
            <view class="face" style="border-radius:100% 100% 0 0">
                <image :src="face" :lazy-load="true"></image>
            </view>
            <view class="username">
                {{username}}的红包
            </view>
        </view>
        <view class="info">
            已领取{{grab_number}}/{{number}}个，共{{surplus_money}}/{{money}}元
        </view>
        <view class="list">
            <view class="row" v-for="(row,index) in grabList" :key="index">
                <view class="left">
                    <image :src="staticPhoto2(row.face)" :lazy-load="true"></image>
                </view>
                <view class="right">
                    <view class="r1">
                        <view class="username">
                            {{row.username}}
                        </view>
                        <view class="money">
                            {{row.money}}元
                        </view>
                    </view>
                    <view class="r2">
                        <view class="time">
                            {{row.time}}
                        </view>
                        <view class="lucky" v-if="row.is_lucky">
                            手气王
                        </view>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>

    import _data from "../../../util/_data";

    export default {
        data() {
            return {
                id: '',
                blessing: "恭喜发财",
                money: 0,
                username: "-",
                face: '/static/theme/default/friend/group.png',
                grab_number: 0,
                number: 1,
                grab_money: '',
                surplus_money: 0,
                grabList: [],
                //动画效果
                radius: '100% 100% 0 0'
            };
        },
        onLoad(options) {
            let _this = this;
            _this.id = options.id;
            if (!this.id) {
                return false;
            }
            _this.$httpSend(
                {
                    path: '/im/get/redEnvelopeGrabList',
                    data: {
                        id: _this.id
                    },
                    success: (data) => {
                        _this.money = data.red_envelope.money;
                        _this.grab_money = data.red_envelope.grab_money;
                        _this.surplus_money = data.red_envelope.surplus_money;
                        _this.number = data.red_envelope.number;
                        _this.grab_number = data.red_envelope.number - data.red_envelope.surplus_number;
                        _this.face = _data.staticPhoto() + data.user_info.face;
                        _this.username = data.user_info.username;
                        _this.grabList = data.grab_list;
                    },
                    error(data) {
                        uni.showModal({
                            content: data.msg,
                        });
                    }
                }
            );
        },
        computed: {
            staticPhoto() {
                return _data.staticPhoto();
            },
        },
        methods: {
            staticPhoto2(aa) {
                return _data.staticPhoto()+aa;
            }
        },
        onPageScroll(e) {
            //e.scrollTop;
            if (e.scrollTop > 100) {
                return;
            }
            let radiusTmp = 100 - e.scrollTop;
            this.radius = radiusTmp + '% ' + radiusTmp + '% 0 0';
        }
    }
</script>

<style lang="scss">
    view {
        display: flex;
        flex-wrap: wrap;
    }

    .top {
        width: 100%;
        background-color: #cf3c35;
        flex-wrap: wrap;

        .blessing, .money {
            width: 100%;
            color: #f8d757;
            padding: 20upx 0;
            justify-content: center;
            font-size: 34upx;
        }

        .money {
            font-size: 100upx;
        }

        .face {
            background-color: #fff;
            justify-content: center;
            width: 100%;
            height: 130upx;
            margin-top: 65upx;
            border-radius: 100% 100% 0 0;
            transition: border-radius .15s;

            image {
                width: 130upx;
                height: 130upx;
                border-radius: 100%;
                margin-top: -65upx;
            }
        }

        .username {
            width: 100%;
            justify-content: center;
            background-color: #fff;
            margin-top: -50upx;
            font-size: 38upx;
        }
    }

    .info {
        margin-top: 30upx;
        width: 100%;
        height: 50upx;
        padding-left: 4%;
        font-size: 28upx;
        color: #999;
        border-bottom: solid 1upx #dfdfdf;
    }

    .list {
        width: 100%;

        .row {
            width: 100%;
            padding: 0 4%;
            height: 120upx;
            border-bottom: solid 1upx #dfdfdf;
            justify-content: flex-start;
            flex-wrap: nowrap;

            .left {
                flex-shrink: 0;
                width: 100upx;
                height: 120upx;
                justify-content: flex-start;
                align-items: center;

                image {
                    width: 80upx;
                    height: 80upx;
                    border-radius: 100%;
                }
            }

            .right {
                width: 100%;
                height: 150upx;

                .r1 {
                    width: 100%;
                    height: 75upx;
                    justify-content: space-between;
                    align-items: center;
                    font-size: 34upx;
                }

                .r2 {
                    width: 100%;
                    height: 75upx;
                    justify-content: space-between;
                    font-size: 26upx;

                    .time {
                        color: #8F8F94;
                    }

                    .lucky {
                        padding: 3upx 8upx;
                        border-radius: 5upx;
                        background-color: #F8D757;
                        align-items: center;
                        height: 38upx;
                        font-size: 24upx;
                        color: #CF3C35;
                    }
                }
            }
        }
    }
</style>
